package com.authine.cloudpivot.ext.dto;

import com.authine.mvp.app.launcher.domain.AttachmentFormat;
import com.authine.mvp.app.launcher.domain.SelectorFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Kris on 2019/3/25
 */
@Data
@Schema(description = "ContractOrderIntentionDto")
@ApiModel("代购意向")
public class ContractOrderIntentionDto {
    @Schema(description = "代购意向ID")
    private String id;
    @Schema(description = "代购意向ID集合")
    private List<String> ids;
    @Schema(description = "创建代购意向表的会员id")
    private SelectorFormat memberId;
    @Schema(description = "供应商组织ID")
    private SelectorFormat vendorOrganizationId;
    @Schema(description = "项目名称")
    private String projectName;
    @Schema(description = "付款条款状态")
    private String contractIntentionStatus;
    @Schema(description = "附件")
    private List<AttachmentFormat> attachments;
    @Schema(description = "备注")
    private String memo;
    @Schema(description = "合同正文")
    private String contractContent;
    @Schema(description = "合同总金额")
    private BigDecimal amount;
    @Schema(description = "操作人")
    private String operator;
    @Schema(description = "成员名称")
    private String memberName;
    @Schema(description = "供应商组织名称")
    private String vendorOrganizationName;
    @Schema(description = "删除")
    private String del;

    /* 代购条款 */
    @Schema(description = "代购条款")
    private List<ContractClauseDto> contractClause;
    /* 代购商品 */
    @Schema(description = "代购商品")
    private List<ContractGoodsDto> contractGoods;

    public static Map<String, Object> voToEntity(ContractOrderIntentionDto dto) {
        Map<String, Object> result = new HashMap<>();
        result.put("member_id", dto.getMemberId());
        result.put("vendor_organization_id", dto.getVendorOrganizationId());
        result.put("project_name", dto.getProjectName());
        result.put("contract_intention_status", dto.getContractIntentionStatus());
        result.put("attachments", dto.getAttachments());
        result.put("memo", dto.getMemo());
        result.put("contract_content", dto.getContractContent());
        result.put("amount", dto.getAmount());
        result.put("operator", dto.getOperator());
        result.put("member_name", dto.getMemberName());
        result.put("vendor_organization_name", null==dto.getVendorOrganizationId()?null:dto.getVendorOrganizationId().getName());
//        result.put("del", false);
        return result;
    }
}
